package com.afc.struts.bustle.products;

import java.util.List;
import java.util.Vector;

import com.afc.struts.bustle.data.ProductDao;
import com.afc.struts.bustle.model.ProductDto;
import com.afc.struts.form.ActionForm;
import com.afc.struts.utils.LabeledBoolean;

public interface ProductsForm extends ActionForm
{
  public List<ProductDto> getProducts();

  public int getSelectedProductId();
  public void setSelectedProductId(int aSelectedProductId);

  public class DefaultProductsForm implements ProductsForm
  {
    @Override
    public List<ProductDto> getProducts()
    {
      return products;
    }

    @Override
    public int getSelectedProductId()
    {
      return selectedProductId;
    }

    @Override
    public void setSelectedProductId(int aSelectedPersonId)
    {
      selectedProductId = aSelectedPersonId;
    }

    @Override
    public LabeledBoolean validateForm()
    {
      return LabeledBoolean.OK;
    }

    protected List<ProductDto> products = new Vector<>(ProductDao.getInstance().retrieveAll());
    protected int selectedProductId;
  }
}
